package com.teichmann.core.util;

import org.htmlparser.Tag;

import com.teichmann.core.annotations.Delimiter;

public class CrawlerUtils {
	
	public static boolean containsDelimiter(Tag tag, Class clazz){
		
		if (((Delimiter)clazz.getAnnotation(Delimiter.class)).tag().equalsIgnoreCase(tag.getTagName())
				&& (((Delimiter)clazz.getAnnotation(Delimiter.class)).attribute()) != null 
				&& tag.getAttribute(((Delimiter)clazz.getAnnotation(Delimiter.class)).attribute()).contains(((Delimiter)clazz.getAnnotation(Delimiter.class)).value())) {

		
			return true;
		}
		return false;
	}
	
	public static String removeUnusedFields(String string){
		String adjusted = null;
		adjusted = string.replaceAll("\n", "");
		adjusted = string.replaceAll("\r", "");
		adjusted = string.replaceAll("\t", "");
		adjusted = string.replaceAll("&nbsp;", "");
		
		return adjusted.trim();
	}
	
}
